package com.cloud.cloudshop.shop.controller;


import com.cloud.cloudshop.client.OrderServiceClient;
import com.cloud.common.annotation.MyCacheable;
import com.cloud.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
@RefreshScope
@Slf4j
public class OrderControllerTest {

    @Resource
    private OrderServiceClient orderServiceClient;

    @GetMapping("/test/{id}")
    @MyCacheable(cacheName = "test",key = "#id",expireInSeconds = 10,waitInSeconds = 3000)
    public R invokeOrderTest(@PathVariable("id") String id){

        R list = orderServiceClient.list();
        return list;
    }
}
